package com.asialjim.wechat.official.qrcode;

import com.asialjim.wechat.official.api.qrcode.GetQrCodeTicketApiRequest;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.databind.ser.std.ObjectArraySerializer;
import lombok.Data;

import java.util.Objects;

/**
 * <h1><em>ASIAL JIM JAVA DOC</em></h1><hr/>
 * <h2>CLASS DESCRIPTION <i>[ NAME: QrCodeProperty ]</i></h2><strong>
 * <p> TODO
 * </strong><p><p><em>Copyright &copy; Asial Jim Co., LTD</em><hr/>
 *
 * @author Asial Jim &nbsp;&nbsp; <span>Email:<a href="mailto:asialjim@hotmail.com">asialjim@hotmail.com</a> &nbsp;&nbsp; <a href="asialjim@qq.com">asialjim@qq.com</a></span>
 * @version 1.0.0
 * @since 2021/3/31   &nbsp;&nbsp; JDK 8
 */
@Data
public class QrCodeProperty {

    @JsonProperty("expire_seconds")
    private Integer expireSeconds;

    @JsonProperty("action_name")
    private String actionName;

    @JsonProperty("scene_id")
    private Integer sceneId;

    @JsonProperty("scene_str")
    private String sceneStr;

    public GetQrCodeTicketApiRequest.BodyParam createApiReqParam(){
        GetQrCodeTicketApiRequest.BodyParam bodyParam = new GetQrCodeTicketApiRequest.BodyParam();

        if (Objects.nonNull(expireSeconds)){
            bodyParam.setExpireSeconds(expireSeconds);
        }

        bodyParam.setActionName(actionName);

        GetQrCodeTicketApiRequest.Scene scene = new GetQrCodeTicketApiRequest.Scene();
        if (Objects.nonNull(sceneId)){
            scene.setSceneId(sceneId);
        }

        if (Objects.nonNull(sceneStr)){
            scene.setSceneStr(sceneStr);
        }

        GetQrCodeTicketApiRequest.ActionInfo actionInfo = new GetQrCodeTicketApiRequest.ActionInfo(scene);
        bodyParam.setActionInfo(actionInfo);
        return bodyParam;
    }

    public static enum QrCodeActionName{
        /**
         * <h3>FIELD DESCRIPTION</h3>
         * 为临时的整型参数值a
         */
        QR_SCENE,
        /**
         * <h3>FIELD DESCRIPTION</h3>
         * 为临时的字符串参数值
         */
        QR_STR_SCENE,
        /**
         * <h3>FIELD DESCRIPTION</h3>
         * 为永久的整型参数值
         */
        QR_LIMIT_SCENE,
        /**
         * <h3>FIELD DESCRIPTION</h3>
         * 为永久的字符串参数值
         */
        QR_LIMIT_STR_SCENE;
    }
}